package com.kipling.kio.demo.common;

import java.util.HashMap;
import java.util.Map;

public enum Command
{

	MSG_REQ((byte) 1, "聊天请求"),	
	MSG_RES((byte) 2, "聊天响应"),
	PUSH_REQ((byte) 3, "推送请求"),
	PUSH_RES((byte) 4, "推送响应"),	
	HEARTBEAT_REQ((byte)99,"心跳请求");

	private byte code;
	private String name;

	private Command(byte code, String name)
	{
		this.setCode(code);
		this.setName(name);
	}

	public byte getCode()
	{
		return code;
	}

	public void setCode(byte code)
	{
		this.code = code;
	}

	private static final Map<Byte, Command> map = new HashMap<Byte, Command>();
	
	static
	{
		for (Command command : values())
		{
			map.put(command.getCode(), command);
		}
	}

	public static Command valueOf(byte code)
	{
		return map.get(code);
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

}
